<? require_once('../include/connect.inc.php');
		session_start();
		
		$query = query("SELECT * FROM tb_set_of_test where set_id=49");
			while ($rs = fetch_array($query)) {
				$set_id= $rs['set_id'];
				$set_time_dotest=$rs['set_time_dotest'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Modeltests Program</title>
</head>

<body>
<table width="100%" border="1">
  <tr>
    <td><font size="+3" color="#FF0000">ตั้งใจทำข้อสอบนะหนูๆ อย่าเสียงดัง ดูเวลา ระวังโดนโกงตวยเน้อ 555++</font></td>
  </tr>
</table>
<form id="form1" name="form1" method="post" action="save.php">
<?
	//เลือกแสดงชุดข้อสอบ จากค่าID ชุดที่เลือกมา
	$count=1;
	$query = query("SELECT * FROM tb_set_detail where set_id='".$_GET['set_id']."'");
    	while ($rs = fetch_array($query)) {
		$question_id=$rs['question_id'];
	//เลือกแสดงข้อสอบ ตามID ของรายละเอียดชุด
		$query2= query("SELECT * FROM tb_question where question_id='".$question_id."'order by   RAND() ");
			while ($rs2= fetch_array($query2)) {
	?>
		<table width="500" border="1">
            <tr>
              <td >
              <p>  <input type="hidden" name="question_id[]" id="question_id[]" value="<? echo $rs2[question_id ]?>" />
                <?  echo $rs2['question_detail']; ?>
              </p>
                  <?
			$query3 = query("SELECT * FROM tb_choice  where question_id=' " .$rs2['question_id']." ' ");
			while ($rs3 = fetch_array($query3))
			{
			?>
                  <table width="200" border="1">
                    <tr>
                      <td><?  if($rs2['type_id']==2){?>
                          <label>
                          <input type="checkbox" name="choice[]<?=$count?>"  value="<? echo $rs3[choice_id];?>" />
                          </label>
                          <? }else{ ?>
                          <label>
                          <input type="radio" name="choice[]<?=$count?>"  value="<? echo $rs3[choice_id];?>" />
                          </label>
                          <? } ?>
                          <?  echo $rs3['choice_detail'];?>
                      </td>
                    </tr>
                  </table>
                <? }?>
              </td>
            </tr>
  </table>
        <p>
          <? $count++; }// }?>
          </td>
            </tr>
          </table>
		<? }?>
	<? }?>
</p>
        <p>
          <input type="submit" name="save" id="save" value="ส่งข้อสอบ" onclick="return confirm('ยืนยันการส่งข้อสอบ')" />
		</p>
</form>
</body>
</html>
